import httpUtils from "./XmlHttpTool";
cc.Class({
    extends: cc.Component,

    properties: {
        closeBtn:cc.Button,
        againGamebtn:cc.Button,
        textfaild:cc.Node,
        moneySuccessGet:cc.Node,
        SvprogressPrefab: cc.Prefab,
        showHubProjess:cc.Node
    },

    closeView:function(){

        this.node.active=false
      
   
     },

     againGame:function(){

        console.log("提现的手机号",this.textfaild.getComponent(cc.EditBox).string);

         if(this.textfaild.getComponent(cc.EditBox).string){
            var that=this
            httpUtils.NhttpPost("/marmot/draw_money",{"phone":this.textfaild.getComponent(cc.EditBox).string},function(res){
                
                console.log("提现成功",res)  
                that.node.active=false
                that.moneySuccessGet.active=true
                that.moneySuccessGet.getComponent("moneySuccessAlertView").init(res["kfWx"])
            
            },function(failres){
                console.log("提现失败",failres)  
                if(cc.isValid(that.showHubProjess)){
                    that.showHubProjess.destroy();
                  }
                  that.showHubProjess = cc.instantiate(that.SvprogressPrefab);
                  that.node.addChild(that.showHubProjess);
                  that.showHubProjess.getComponent('SVProgressView').init("请输正确的手机号码！")
            
                   let finish = cc.callFunc(() => { 
                  
                    that.showHubProjess.destroy();
                
                  }, that);
                let action = cc.sequence(cc.fadeIn(0.6), cc.delayTime(0.5), cc.fadeOut(1), finish);
                that.showHubProjess.runAction(action);
    
            })
         }else{

            if(cc.isValid(this.showHubProjess)){
                this.showHubProjess.destroy();
              }
              this.showHubProjess = cc.instantiate(this.SvprogressPrefab);
              this.node.addChild(this.showHubProjess);
              this.showHubProjess.getComponent('SVProgressView').init("手机号码为空")
        
               let finish = cc.callFunc(() => { 
              
                this.showHubProjess.destroy();
            
              }, this);
            let action = cc.sequence(cc.fadeIn(0.6), cc.delayTime(0.5), cc.fadeOut(1), finish);
            this.showHubProjess.runAction(action);
            return
         }
       
    
     },

    // onLoad () {},

    start () {

    },

    // update (dt) {},
});